import os
import pandas as pd
from flask import request, send_from_directory
from dash import get_app
from dash import (
    dcc,
    html,
    callback,
    Output,
    Input,
    State,
    register_page,
)
from ddbtools import (
    BaseCRUD,
    DBDf,
    Filter,
    Comparator,
    get_table_info,
    get_table_columns,
)

import feffery_antd_components as fac
from pathlib import Path

from gypb.db import get_db
from gypb.component import CRUDTable
from gypb.config import settings


app = get_app()
register_page(__name__, name="代销项目资料管理", order=10)

basedir = settings.custom_dir
if not basedir:
    basedir = Path.home().joinpath(".gypb")

sale_file_dir = Path(basedir).joinpath("sale_files")
if not os.path.exists(sale_file_dir):
    os.makedirs(sale_file_dir)

class SaleFileTable:
    def __init__(self):
        pass
    def layout(self):
        return fac.AntdTable()
    
def layout():
    return html.Div(
        [
            fac.AntdAccordion(
                items=[
                    {
                        "title": "问卷-评估",
                        "key": 1,
                        "children": fac.AntdDescriptions(
                            items=[
                                {
                                    "label": "尽调问卷",
                                    "children": "上传",
                                    "style": {"label": {"fontWeight": "bold"}},
                                },
                                {
                                    "label": "净值模板",
                                    "children": "上传",
                                    "style": {"label": {"fontWeight": "bold"}},
                                },
                                {
                                    "label": "评估报告",
                                    "children": "上传",
                                },
                            ],
                            # title="描述列表示例",
                            bordered=True,
                            # column=2,
                        ),
                        "extra": fac.AntdButton("额外内容", type="link", size="small"),
                    },
                    {
                        "title": "尽调材料",
                        "key": 2,
                        "children": fac.AntdDescriptions(
                            [
                                fac.AntdDescriptionItem("费弗里", label="姓名"),
                                fac.AntdDescriptionItem(
                                    html.A(
                                        "https://github.com/CNFeffery",
                                        href="https://github.com/CNFeffery",
                                    ),
                                    label="个人Github地址",
                                ),
                                fac.AntdDescriptionItem(
                                    html.A(
                                        "https://www.cnblogs.com/feffery/",
                                        href="https://www.cnblogs.com/feffery/",
                                    ),
                                    label="个人博客地址",
                                ),
                                fac.AntdDescriptionItem(
                                    html.A(
                                        "http://fac.feffery.tech/",
                                        href="http://fac.feffery.tech/",
                                    ),
                                    label="fac框架官网",
                                ),
                            ],
                            title="描述列表示例",
                            bordered=True,
                            style={"label": {"fontWeight": "bold"}},
                        ),
                        "extra": fac.AntdButton("额外内容", type="link", size="small"),
                    },
                ],
                collapsible="header",
                accordion=False,
            )
        ]
    )
